﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		depId = sessionAdvice.getUserProp("teacherDepartment");
		teacherId = sessionAdvice.getAutherUserID();
		
		targetGrade = event.getArg("Edition", year(now()));
		targetSubject = event.getArg("SubjectID");
		
		signId = event.getArg("REQ");
		
		sql = "	SELECT
					sbj.sbj_id,sbj.sbj_name
				FROM
					t_subject sbj
				WHERE
					sbj.sbj_id LIKE '_____'
					AND
					sbj.institute_id = :depID 
				ORDER BY
					sbj.sbj_name";
		
		queryObj = new Query(datasource = application.dnsSlave);
		
		queryObj.addParam(name="depID", value=depID, cfsqltype="cf_sql_varchar");
		
		rs_subject = queryObj.execute(sql=sql).getResult();
		
		sql = "	SELECT
					sm.sign_id,
					t.tch_name,
					sm.grade,sbj.sbj_name,
					sm.sign_reason,
					sm.sign_status,
					sm.date_created,sm.date_valid
				FROM
					t_schema_modify sm
					INNER JOIN t_teacher t ON t.tch_id = sm.sign_user_id
					INNER JOIN t_subject sbj ON sbj.sbj_id = sm.sbj_id
				WHERE
					sbj.institute_id = :depId 
				ORDER BY
					sm.date_created DESC";
					
		queryObj = new Query(datasource = application.dnsSlave);
		
		queryObj.addParam(name="depId", value=depId, cfsqltype="cf_sql_varchar");
		
		rs_sign = queryObj.execute(sql=sql).getResult();

		event.setArg("pageTitle", "教学运行基础数据 - 培养方案 - 申请培养方案修订");
		
		currentTab = event.getArg("TabID", "labApply");
		
		passArgs = structNew();
		
		rs_signEntity = queryNew("sign_id");
		
		if ( len(signId) ) {

			sql = "	SELECT
						sm.sign_id,
						sm.sign_status,
						tch.tch_name,
						sm.date_created,
						sm.sign_reason
					FROM
						t_schema_modify sm
						INNER JOIN t_teacher tch ON tch.tch_id = sm.sign_user_id
					WHERE
						sm.sign_id = :signId ";
			
			queryObj = new Query(datasource = application.dnsSlave);
		
			queryObj.addParam(name="signId", value=signId, cfsqltype="cf_sql_char");
			
			rs_signEntity = queryObj.execute(sql=sql).getResult();
			
			currentTab = "labRequest";
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programSchema')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">培养方案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>培养方案修订申请
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labApply">class="active"</cfif> id="labApply" tabTarget="Apply">申请修改培养方案</span>
						<cfif rs_signEntity.recordCount>
							<span <cfif currentTab eq "labRequest">class="active"</cfif> id="labRequest" tabTarget="Request">申请内容</span>
						</cfif>
						<cfif rs_sign.recordCount>
							<span <cfif currentTab eq "labHistory">class="active"</cfif> id="labHistory" tabTarget="History">申请历史记录</span>
						</cfif>
					</div>
				</div>

				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Apply" class="tabContent">
					
					<cfif event.isArgDefined("msgWarn")>
						<div class="systemNotice">
							<cfoutput>#event.getArg("msgWarn")#</cfoutput>
						</div>
					</cfif>
					
					<form id="applyCreate" onSubmit="javascript:return processVerfiyForm('applyCreate');" class="formWrapper" method="post" action="<cfoutput>#buildURL('schemaModifyApplyDo')#</cfoutput>">
						
						<input name="InstituteID" type="hidden" value="<cfoutput>#depId#</cfoutput>" />
						<input name="TeacherID" type="hidden" value="<cfoutput>#teacherId#</cfoutput>"/>
						
						<div class="label">
							<b>修订专业</b>
							<select id="SubjectID" name="SubjectID">
                                <cfloop query="rs_subject">
									<option <cfif rs_subject.sbj_id eq targetSubject>selected="selected"</cfif> value="<cfoutput>#rs_subject.sbj_id#</cfoutput>"><cfoutput>#rs_subject.sbj_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<div class="label">
							<b>培养方案版本</b>
							<select id="Edition" name="Edition">
								<cfloop from="#(year(now())-4)#" to="#(year(now())+1)#" index="grade">
								<option <cfif grade eq targetGrade>selected="selected"</cfif> value="<cfoutput>#grade#</cfoutput>"><cfoutput>#grade#</cfoutput>版</option>
								</cfloop>
							</select>
						</div>
						
						<div class="label">
							<span class="req">*</span><b>修订原因</b>
							<textarea id="ChangeReason" name="ChangeReason" verification="required"><cfoutput>#event.getArg("ChangeReason")#</cfoutput></textarea>
							<p class="notice">请根据实际需要描述培养方案的修订原因</p>
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button1" type="reset" value="重设表单" />
						</div>
						
					</form>
					
				</div>
				
				<cfif rs_signEntity.recordCount>
					
					<div id="Request" class="tabContent">
						
						<div class="noticeBlock">
							<cfif rs_signEntity.sign_status eq "W">

								<cfset structInsert( passArgs, "REQ", signId, true) />
								<cfset structInsert( passArgs, "TabID", "labHistory", true) />

								<div class="operation">
									<a class="uiButton" href="<cfoutput>#buildURL('schemaModifyApplyCancelDo', passArgs)#</cfoutput>"><i class="mrs img btnClear"></i><span class="uiButtonText">撤销申请</span></a>
								</div>
								
								<cfset structDelete( passArgs, "TabID", false ) />
								
							</cfif>
							<h3>培养方案变更申请</h3>
							<p>
								<span class="img icon16x16 message"></span>
								该请求已成功提交, 请等待下一步工作流程处理. 执行序号 <b><cfoutput>#rs_signEntity.sign_id#</cfoutput></b>
							</p>
							<hr/>
						</div>
						
						<div class="UIDashBoard">
							<div class="col2">
								<div class="noticeBlock">
									<p>学院申请变更</p>
									<ol>
										<li>申请人: <cfoutput>#rs_signEntity.tch_name#</cfoutput></li>
										<li>提交时间: <cfoutput>#datetimeAdvice.formatDateString( rs_signEntity.date_created, "YYYY年MM月DD日" )#</cfoutput></li>
										<li>变更原因: <cfoutput>#stringAdvice.XHTMLSafeFormat( rs_signEntity.sign_reason )#</cfoutput></li>
										<li>状态: <cfoutput>#dictAdvice.getProgressStatus( rs_signEntity.sign_status )#</cfoutput></li>
									</ol>
								</div>
							</div>
							<div class="col2 last">
								<div class="noticeBlock">
									<p>申请回执单号</p>
									<p>
										<span class="img icon16x16 message"></span>
										该回执单号仅用于核查工作流信息
									</p>
									<br/>
									<p><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Progress/PRGS-SCH-<cfoutput>#rs_signEntity.sign_id#</cfoutput>.png" /></p>
								</div>
							</div>
						</div>
						
						<div class="clearfix"></div>
						
					</div>
					
				</cfif>
				
				<cfif rs_sign.recordCount>
					
					<div id="History" class="tabContent">
						
						<div class="noticeBlock">
							<h3>培养方案修订申请 历史记录</h3>
							<hr/>
						</div>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="60">申请人</td>
									<td width="140">对象</td>
									<td>修订原因</td>
									<td width="60">审批进程</td>
									<td width="70">申请时间</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_sign">
									<cfset row ++ />
									<cfset structInsert(passArgs, "REQ", rs_sign.sign_id, true) />
									
									<tr class="editRows <cfif event.getArg('REQ') eq rs_sign.sign_id> lastEdited</cfif>">
										<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
										<td><cfoutput>#rs_sign.tch_name#</cfoutput></td>
										<td><cfoutput>#rs_sign.sbj_name#</cfoutput> <span class="numeric"><cfoutput>#rs_sign.grade#</cfoutput></span>版</td>
										<td><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_sign.sign_reason )#</cfoutput></td>
										<td><cfoutput>#dictAdvice.getProgressStatus( rs_sign.sign_status )#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#datetimeAdvice.formatDateString( rs_sign.date_created, "YYYY/MM/DD" )#</cfoutput></span></td>
										<td><a class="stat info" href="<cfoutput>#buildURL('schemaModifyApply', passArgs)#</cfoutput>"></a></td>
									</tr>
																		
								</cfloop>
							</tbody>
						</table>
						
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>